﻿<!doctype html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <link rel="stylesheet" href="../css/mui.min.css" />
        <link rel="stylesheet" href="../css/custom.july.css" />
        <link rel="stylesheet" href="../fonts/iconfont.css" />
    </head>
    <body style="background: #fff;">
        <div class="mui-content ju-login-wrap">
            <div class="loginmask">
                <!--纯装饰-->
                <div class="logo-wrap">
                </div>
            </div>
            <div class="cont">
                <div class="mui-text-right">
                    <a href="../html/Register.html" class="link">注册</a>
                </div>
                <form class="ju-form ju-login-form">
                    <div class="mui-input-row">
                        <label>账号 :</label>
                        <input type="text" name="username" placeholder="请输入账号">
                    </div>
                    <div class="mui-input-row">
                        <label>密码 :</label>
                        <input type="password" class="input-pwd" name="password" placeholder="请输入密码">
                        <i class="iconfont pwd-clear icon-close"></i>
                        <a class="pwd-visible invisible">
                            <i class="iconfont icon-visible"></i>
                            <i class="iconfont icon-invisible"></i>
                        </a>
                    </div>
                    <div class="opts">
                        <button type="submit" data-loading-text="登录中" class="mui-btn mui-btn-grad-blue mui-btn-block btn-login">登录</button>
                    </div>
                </form>
            </div>
        </div>
        <script src="../js/mui.min.js"></script>
        <script src="../fonts/iconfont.js"></script>
        <script src="../js/dw-wheel.js"></script>
        <script type="text/javascript">
            var uname = "";
            var pwd = "";
            var mDevId = "";
            var versionId = "";

            function setDevMes(unameApp, pwdApp, devId, versionId) {
                //alert(devId+simId+phoneNum+devName);
                uname = unameApp;
                pwd = pwdApp;
                mDevId = decodeURI(devId);
                localStorage.setItem('devId',devId);
               // localStorage.setItem('versionId', decodeURI(versionId));
                //document.getElementById("username").setValue(devId);
            }

            function pwdVisible(flag) {
                if(flag) {
                    mui('.pwd-visible').removeClass('invisible');
                    mui('.input-pwd')[0].setAttribute('type', 'text')
                } else {
                    mui('.pwd-visible').addClass('invisible');
                    mui('.input-pwd')[0].setAttribute('type', 'password')
                }
            }

            function togglePwdVisible(e) {
                if(this.classList.contains('invisible')) {
                    pwdVisible(true)
                } else {
                    pwdVisible(false)
                }
            }

            function clearPwd() {
                mui('.input-pwd')[0].value = '';
                mui('.pwd-clear')[0].style.visibility = 'hidden';
            }

            function showPwdClear() {
                mui('.pwd-clear')[0].style.visibility = 'visible';
            }

            function actionLogin() {

                var type = 2; //设备类型
                var flag = 0; //自动登录判断
                
                document.activeElement.blur();
                var isIphone = (/iphone/).test(navigator.userAgent);
                var isAndroid = (/Android/).test(navigator.userAgent);

                if(isIphone == "true") {
                    type = 1;
                } else if(isAndroid) {
                    type = 0;
                }
                
                if((uname.length == 0) || (pwd.length == 0)) {
                    uname = mui('input[name="username"]')[0].value === undefined ? '' : mui('input[name="username"]')[0].value,
                    pwd = mui('input[name="password"]')[0].value === undefined ? '' : mui('input[name="password"]')[0].value;
                }else{
                    flag = 1;
                }
                
                //请求前判断
                if(uname.length <= 0 || pwd.length <= 0) {
                    mui.toast('请输入账号和密码');
                    return false;
                }
                
                //通过前台验证，锁定登录操作
                if(flag == 0){
                	//手动登录，显示加载动画
                    mui('.btn-login').button('loading');    
                }
                setTimeout(function(){
                	mui.openWindow({url:"../html/Layout.html"});
                	mui('.btn-login').button('reset')
                })
            }

            /*
             * init and bindings
             */
            mui.init()
            mui('.ju-login-wrap')
                .on('tap', '.pwd-visible', togglePwdVisible)
                .on('tap', '.pwd-clear', clearPwd)
                .on('input', '.input-pwd', showPwdClear)
                .on('submit', 'form', function(e) {
                    e.preventDefault()
                    actionLogin()
                })
            mui('body').on('tap', '.link', function() {
                var href = this.href;
                mui.openWindow({url:href})
            });
        </script>
    </body>
</html>